package com.gadgets.busi.bm01.controller;

import com.gadgets.busi.bm01.dto.ImgCopyRestDTO;
import com.gadgets.busi.bm01.dto.TxtCopyFileDTO;
import com.gadgets.busi.bm01.dto.TxtCopyQueryDTO;
import com.gadgets.busi.bm01.dto.TxtCopyRestDTO;
import com.gadgets.busi.bm01.fegin.IImgCoptController;
import com.gadgets.busi.bm01.fegin.ITxtCopyController;
import com.gadgets.busi.bm01.pojo.CopyTxtTask;
import com.gadgets.framework.annotation.RoleAuthCheck;
import com.gadgets.framework.common.dto.HttpBaseResp;
import com.gadgets.framework.common.dto.Pagination;
import com.gadgets.framework.common.exception.GadgetsServiceException;
import com.gadgets.framework.common.util.FeginRequestMapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/**
 * 功能说明：
 *
 * @author Unclexiu
 * @version V202101.00.000
 * @data 2022-09-14
 * 修改记录：  修改日期          修改人员    修改说明
 * 2022-09-14  xiujunqing   创建文件
 */
@RestController
@RequestMapping(value = "/bm01")
public class GadgetsBm01ForkController {

	@Autowired
	private IImgCoptController imgCoptController;
	@Autowired
	private ITxtCopyController txtCopyController;

	/**
	 * 图片拷贝
	 * @param request                   网络请求
	 * @param response                  网络应答
	 * @param imgCopyRestDTO            图片拷贝请求信息
	 * @return                          统一应答结果
	 * @throws GadgetsServiceException  异常信息
	 */
	@RoleAuthCheck
	@RequestMapping(value = "/imgCopy.do")
	public HttpBaseResp copyImg(HttpServletRequest request, HttpServletResponse response, ImgCopyRestDTO imgCopyRestDTO) throws GadgetsServiceException{
		HashMap<String,Object> requestMap = new HashMap<>();
		FeginRequestMapUtil.parseRequestParam(imgCopyRestDTO, requestMap);
		return imgCoptController.copyImg(requestMap);
	}

	/**
	 * 文本拷贝请求（RestFul请求）
	 *
	 * @param request        网络请求信息
	 * @param response       网络应答信息
	 * @param txtCopyRestDTO 文本RestFul请求信息
	 * @throws GadgetsServiceException 异常信息
	 */
	@RoleAuthCheck
	@RequestMapping(value = "/txtCopy.do")
	void requestTxtCopy(HttpServletRequest request, HttpServletResponse response, TxtCopyRestDTO txtCopyRestDTO) throws GadgetsServiceException{
		HashMap<String,Object> requestMap = new HashMap<>();
		FeginRequestMapUtil.parseRequestParam(txtCopyRestDTO, requestMap);
		txtCopyController.requestTxtCopyForRestful(requestMap);
	}

	/**
	 * 文本拷贝请求（文本文件请求）
	 *
	 * @param request        网络请求信息
	 * @param response       网络应答信息
	 * @param txtCopyFileDTO 文件请求信息
	 * @throws GadgetsServiceException 异常信息
	 */
	void requestTxtCopy(HttpServletRequest request, HttpServletResponse response, TxtCopyFileDTO txtCopyFileDTO) throws GadgetsServiceException{

	}

	/**
	 * 分页条件查询文本拷贝任务
	 * @param request                       网络请求
	 * @param response                      网络应答
	 * @param queryDTO                      查询条件
	 * @param pagination                    分页条件
	 * @return                              查询结果
	 * @throws GadgetsServiceException      异常信息
	 */
	@RoleAuthCheck
	@RequestMapping(value = "/selectTxtCopyTask.do")
	public HttpBaseResp<CopyTxtTask> queryTxtCopyByCondition(HttpServletRequest request, HttpServletResponse response, TxtCopyQueryDTO queryDTO, Pagination pagination) throws GadgetsServiceException{
		HashMap<String,Object> requestMap = new HashMap<>();
		FeginRequestMapUtil.parseRequestParam(queryDTO, requestMap);
		FeginRequestMapUtil.parseRequestParam(pagination, requestMap);
		return txtCopyController.queryTxtCopyByCondition(requestMap);
	}

}
